package com.newlink.building.userinfo.mvp

import android.util.Log
import com.newlink.building.common_base.base.BasePresenter
import com.newlink.building.common_base.ext.ss
import com.newlink.building.common_base.model.bean.DeleteFaceDataRequest
import com.newlink.building.common_base.model.bean.LoadFaceListDataRequest
import com.newlink.building.common_base.model.bean.UploadFaceDataRequest
import com.newlink.building.userinfo.mvp.contract.Module_UserInfo_AuthFaceContract
import com.newlink.building.userinfo.mvp.model.Module_UserInfo_AuthFaceModel

/**
 * @author wangyang
 * @date 2022/9/20
 * @description 我的-关于页面的Presenter
 */
class Module_UserInfo_AuthFacePresenter : BasePresenter<Module_UserInfo_AuthFaceContract.Model, Module_UserInfo_AuthFaceContract.View>(),
    Module_UserInfo_AuthFaceContract.Presenter {

    override fun createModel(): Module_UserInfo_AuthFaceContract.Model? = Module_UserInfo_AuthFaceModel()

    override fun getFaceData(request: LoadFaceListDataRequest) {
        mModel?.getFaceData(request)?.ss(mModel, mView) {
            if (it?.data != null) {
                mView?.onFaceListDataSuccess(it?.data?.list)
            }
        }
    }

    override fun removeFaceData(request: DeleteFaceDataRequest) {
        mModel?.removeFaceData(request)?.ss(mModel, mView) {
            if (it?.code == 200) {
                mView?.onDeleteFaceDataSuccess()
            } else {
                mView?.onDeleteFaceDataFailed()
            }
        }
    }

    override fun uploadFaceData(request: UploadFaceDataRequest) {
        mModel?.uploadFaceData(request)?.ss(mModel, mView) {
            if (it?.code == 200) {
                mView?.onUploadFaceDataSuccess()
            } else {
                mView?.onUploadFaceDataFailed(it?.msg)
            }
        }
    }

    override fun checkFaceValid(token: String, mBase64: String) {
        mModel?.checkFaceValid(token, mBase64)?.ss(mModel, mView) {
            Log.d("jake", "onCheckFaceValidSuccess >>> $it")
            if (it?.code == 200) {
                mView?.onCheckFaceValidSuccess()
            } else {
                mView?.onCheckFaceValidFail()
            }
        }
    }

//    override fun onAuthListResponse(
//        id: Int, result: KcpResult<FaceListData>?
//    ) {
//        Log.d("jake", "onAuthListResponse >>> ${result?.data?.total}")
//        Log.d("jake", "onAuthListResponse >>> ${result?.data?.list}")
//        mView?.onFaceListDataSuccess(result?.data?.list)
//    }
//
//    override fun onAuthConfirmResponse(
//        id: Int, result: BaseBean?
//    ) {
//        Log.e("jake", "onAuthConfirmResponse >>> ${result?.code}")
//        if (result?.code == 200) {
//            if (result?.responseType == KcpRquestType.TYPE_APPKEY_ADD) {
//                mView?.onUploadFaceDataSuccess()
//            } else if (result?.responseType == KcpRquestType.TYPE_APPKEY_DELETE) {
//                mView?.onDeleteFaceDataSuccess()
//            }
//        } else {
//            if (result?.responseType == KcpRquestType.TYPE_APPKEY_ADD) {
//                mView?.onUploadFaceDataFailed(result?.msg)
//            } else if (result?.responseType == KcpRquestType.TYPE_APPKEY_DELETE) {
//                mView?.onDeleteFaceDataFailed()
//            }
//        }
//    }

}